<template>
  <el-table :data="list">
    <el-table-column prop="fingerprintName" label="姓名" min-width="150px" />
    <el-table-column prop="lockAlias" label="智能锁" min-width="120px" />
    <el-table-column prop="senderName" label="添加者" min-width="150px" />
    <el-table-column prop="startDate" label="有效期" min-width="280px">
      <template #default="scope">
        {{ scope.row.startDate }} - {{ scope.row.endDate }}
      </template>
    </el-table-column>
    <el-table-column prop="status" label="状态" min-width="80px" />
    <el-table-column prop="date" label="操作" min-width="200px">
      <template #default="scope">
        <el-button link type="primary" @click="handleEdit(scope.row)">修改有效期</el-button>
        <el-button link type="primary" @click="handleDelete(scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <EditExpirationDate
    :visible="editExpirationVisible"
    :value="rowData"
    @cancel="() => editExpirationVisible = false"
    @ok="handleEditExpirationDateOk">
      <template #default="scope">
        <el-form-item prop="fingerprintName" label="姓名">
          {{ scope.form.fingerprintName }}
        </el-form-item>
      </template>
    </EditExpirationDate>
</template>
<script setup name="IcCardPane">
import EditExpirationDate from './component/editExpirationDate.vue'


const { proxy } = getCurrentInstance()

const editExpirationVisible = ref(false)
const rowData = ref({})
const list = ref([
  {
    "lockAlias": "劲叶公寓0201",
    "fingerprintType": 1,
    "endDate": '2024-12-23 12:33:11',
    "lockId": 8310551,
    "senderName": "公司管理员",
    "lockData": "ICbig5Ouj0Dj/oSvCMkeYGnTsj6nQ8BrBfvSaHHKzAYEJ13ylJDD0XgoMaRL6E+pJwCjmwGKHICv2bEEShpA9zDzipVbDBM2HRg80A5pHDQ5ChuMGEQeQNrJ4O5Yh0Gapqgt8KnUJjOpXLEe3ry3knK5pCNC/8MMhbCpRr/li5OgfIorjGat/vGDocgfmV5gu1W5helNYZpzHRzM6g4/+FuKoPLt/wInpmILWfHJaRPKVVhzW962ZGvvqgfQKIgP8UmbDHl8Q/UkiksLzyp1sTfCEuZy5uMDHN+L6cm8c237kKxcnOj6Gukq/i04QaMg6EJcb4QpLgH0TGfd8ZTFUFuLFZl1ww+U0Xp/rdzWhzdylG5A/fcPtTfJyLowOIkHsxCwNP+qZ4wEEbXFJj9FyqZuK7U0P43A0RresKOlImIwJkwtuujLwnjzeG/ObM4RtHCxqfThYbo/HrzAl7OuIHv0CkWfq6xGF2YWgKwlcRYVql1t5JAwjjPz2mMXUe8rU/UpwlWAqfESmH9Mp10Vxu37WxlU3OLqcx3vUx9zfVlma3VjEKNHvfzHlcsCFScUhr7CJmwE2ao1lhxDfkdN4uyoidYSZ5Tacf2OnoQfGUlywLQERds=",
    "fingerprintNumber": "48044195119104",
    "fingerprintName": "翟传栋",
    "gatewayFlag": 1,
    "lockVersion": {
      "groupId": 1,
      "protocolVersion": 3,
      "protocolType": 5,
      "orgId": 1,
      "scene": 2
    },
    "fingerprintId": 13850495,
    "startDate": '2024-12-23 12:33:11',
    "status": 1,
    "createDate": 1679752169000
  }
])

// 修改有效期
function handleEdit(row) {
  rowData.value = row
  editExpirationVisible.value = true
}


// 删除指纹
function handleDelete(row) {
  proxy.$modal.confirm('确定删除指纹？').then(() => {
    return true
  }).then(() => {
    proxy.$modal.msgSuccess('删除成功');
  }).catch(() => {})
}

// 修改有效期弹窗确认事件
function handleEditExpirationDateOk(form) {
  console.log(form);
  editExpirationVisible.value = false
}
</script>
